package com.learn.retry.controller;

import cn.hutool.json.JSONUtil;
import com.learn.retry.entity.User;
import com.learn.retry.service.UserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Retry框架实现经典重试场景
 * @author:         MI
 * @email:          448341911@qq.com
 * @createDate:     2023/10/29 18:19
 * @updateUser:     MI
 * @updateDate:     2023/10/29 18:19
 * @updateRemark:   修改内容
 * @version:        v1.0
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/retry")
public class RetryController {


    private final UserService userService;


    @PostMapping("/save")
    public Object save(@Validated @RequestBody User user) {
        log.info("==========ValidEnumController#save==========", JSONUtil.toJsonStr(user));
        userService.saveUser(user);
        return user;
    }
}
